﻿package com.sz.manager.dao.impl;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.sz.common.ConstDefine;
import com.sz.common.crypt.AESCrypt;
import com.sz.manager.dao.IManagerDAO;

public class ManagerDAO extends SqlMapClientDaoSupport implements IManagerDAO{
	
	@SuppressWarnings("unchecked")
	public List queryManagerModules(String manager_id) throws SQLException {
		return this.getSqlMapClient().queryForList("manager_sqlmap.select_ManagerModules", manager_id);
	}

	@SuppressWarnings("unchecked")
	public long addManager(Map map) throws Exception {
		//对密码进行加密处理
		String str = (String)map.get("PASSWORDS");
		if(str == null || str.trim().equals("") == true) {
			return 0;
		} else {
			str = AESCrypt.encrypttoStr(str, ConstDefine.s_cryptKey);
			map.put("PASSWORDS", str);
		}
		
		Object r = this.getSqlMapClient().insert("manager_sqlmap.insert_Manager", map);
		return Long.parseLong(r.toString());
	}
}
